package exam.Data;

import android.app.*;
import android.content.*;
import android.database.*;
import android.net.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import exam.AndroidExam.*;

public class CallWordCP extends Activity {
	static final String WORDURI = "content://exam.Data.EnglishWord/word";
	EditText mText;
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.data_callwordcp);

		mText = (EditText)findViewById(R.id.edittext);

		findViewById(R.id.readall).setOnClickListener(mClickListener);
    }
    
	Button.OnClickListener mClickListener = new Button.OnClickListener() {
		public void onClick(View v) {
			ContentResolver cr = getContentResolver();
			if(v.getId() == R.id.readall){
				Cursor cursor = cr.query(Uri.parse(WORDURI), null, null, null, null);
				
				String Result = "";
				while (cursor.moveToNext()) {
					String eng = cursor.getString(0);
					String han = cursor.getString(1);
					Result += (eng + " = " + han + "\n");
				}

				if (Result.length() == 0) {
					mText.setText("Empyt Set");
				} else {
					mText.setText(Result);
				}
				cursor.close();
			}
		}
	};
 }
